<?php
/**
 * Created by PhpStorm.
 * User: 颖inv
 * Date: 2016/11/15
 * Time: 9:49
 */
session_start();
//判断SESSION中是否存在用户信息
if (isset($_SESSION['username'])){
    $login=true;
    $userinfo=$_SESSION['userinfo'];
}else{
    $login=false;
}
require 'user_html.php';

session_start();//启动SESSION
//用户退出
if (isset($_GET['action']) && $_GET['action']=='logout') {
    //清除Cookie数据
    setcookie('username','',time()-1);
    setcookie('password','',time()-1);
    //清除SESSION数据
    unset($_SESSION['userinfo']);
    //如果SESSION中没有其他数据，则销毁SESSION
    if (empty($_SESSION)) session_destroy();
    header('Location: login.php');
    die;
}    
?>